<?php

/**
 * @Author: Mr.Mao
 * @Date:   2021-05-26 17:18:49
 * @Last Modified by:   Mr.Mao
 * @Last Modified time: 2021-05-27 16:48:42
 */
namespace app\weixin\controller\sys_admin;
use app\AdminController;
use app\weixin\model\WeixinVideoOrderModel;
/**
 * 自定义交易组件订单
 * Class Index
 */
class VideoOrder extends AdminController
{
	/*------------------------------------------------------ */
	//-- 优先执行
	/*------------------------------------------------------ */
	public function initialize(){
        parent::initialize();
        $this->Model = new WeixinVideoOrderModel();
        $this->assign('status',[10=>'待付款',11=>'支付完成',20=>'待发货',30=>'待收货',100=>'完成',200=>'完成售后',250=>'取消']);
    }

    /**
     * [videoGoods 视屏号商品列表]
     */
    public function index()
    {
    	$this->getList(true);
    	return $this->fetch('index');
    }

    /*------------------------------------------------------ */
    //-- 获取列表
    //-- $runData boolean 是否返回模板
    /*------------------------------------------------------ */
    public function getList($runData = false) {
        $where = [];
       
        $data = $this->getPageList($this->Model,$where,'out_order_id,order_id,id,openid');

        foreach ($data['list'] as $key => $value) {
        	$param = [];
        	$param['order_id'] = $value['order_id'];
        	$param['openid'] = $value['openid'];
        	$id = $value['id'];
        	$res = $this->Model->getOrderInfo($param);
        	$value = $res['order'];
        	$value['id'] = $id;
        	$data['list'][$key] = $value;
        }

        // print_r($data);

        $this->assign("data", $data);
        if ($runData == false){
            $data['content']= $this->fetch('list')->getContent();
            unset($data['list']);
            return $this->success('','',$data);
        }
        return true;
    }

    // public function info()
    // {
    //     $id = input('id');
    //     if ($id < 1) {
    //         return $this->error('传参错误.');
    //     }
    //     $info = $this->Model->find($id);
    //     if (empty($info)) {
    //         return $this->error('订单不存在.');
    //     }

    //     $param = [];
    //     $param['order_id'] = $value['order_id'];
    //     $param['openid'] = $value['openid'];

    //     return $this->fetch('info');
    // }

}